<script>
	var dodelete='__URL__/dodelete';
	var dobatchdelete='__URL__/dobatchdelete';
	var doalldelete='__URL__/doalldelete';
</script>
<!--table部分-->
<div class='col-md-12'>
	<!--开始-->
	<table class='table table-hover table-striped table-bordered table-responsive' id='NBtb'>
		<thead>
			<tr>
				<th>#</th>
				<th>序号</th>
				<volist name='thls' id='thv'>
					<th>{$thv}</th>
				</volist>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<volist name='mls' id='mv'>
				<tr>
					<td><input type='checkbox'  autocomplete="off" id="ckb_<?php echo $mv[$mdmklow.'id'] ?>" class='ckb'></td>
					<td>{$pagestart+$i}</td>
					<?php foreach ($mv as $key => $value) {
						if(!in_array($key,$hide_fld)){
					?>
						<?php if(in_array($key,$pic)){ ?>
						<?php if($value){ $picpath=$value; }else{ $picpath=$pic_dflt; } ?>
						<td><img class='img-circle' style="height:40px;width:40px;border:1px solid #ccc" src='{$picpath}'></td>
						<?php }else{ ?>
						<td>{$value}</td>
						<?php } ?>
					<?php 
						}
					} ?>
					<td>
					<?php if($atho['athv']){ ?><a class='btn btn-success btn-mini' href="__URL__/view/id/<?php echo $mv[$lowmdmk.'id'] ?>">查看</a><?php } ?>
					<?php if($atho['athm']){ ?><a class='btn btn-warning btn-mini' href="__URL__/update/id/<?php echo $mv[$lowmdmk.'id'] ?>">修改</a><?php } ?>
					<?php if($atho['athd']){ ?><a class='btn btn-danger btn-mini' onclick="dlt(<?php echo $mv[$lowmdmk.'id'] ?>)" >删除</a><?php } ?>
					</td>
				</tr>
			</volist>
			
		</tbody>
	</table>
	
	<!--结束-->
	{$page}
	<?php if($atho['atha']){ ?><div style='padding-bottom:20px'><a class='btn btn-primary' href='__URL__/update/id/0'>添加</a></div><?php } ?>
	<?php if($atho['athd']){ ?><button class='btn btn-danger' id='batchdelete'>批量删除</button><button class='btn btn-warning' id='alldelete'>全部删除</button><?php } ?>
</div>

<script type="text/javascript">

</script>
<script type="text/javascript">$("#NBtb thead").smartFloatTB();</script>
<script type="text/javascript">
function dlt(id){
	if(confirm("{$deleteconfirm}")){
		$.ajax({
            'type': 'GET',
            'url':dodelete,
            'async':false,  
            'contentType': 'application/json',
            'data': {'id':id},
            'dataType': 'json',
            'success': function(data) {
            	msg('删除成功！',1);
            	console.log("success");
            },
            'error':function() {
                console.log("error");
            }
        });
	}
}
</script>
<script type="text/javascript">
$(function(){
	$('#batchdelete').click(function(){
		if(confirm('确定要批量删除吗？')){
			var ckbls=$('.ckb');
			var id_str='-';
			for(var i=0;i<ckbls.size();i++){
				ckbo=ckbls[i];var id_ckb=$(ckbo).attr('id').split('ckb_')[1];
				if($(ckbo).is(':checked')){
				  id_str=id_str+id_ckb+'-';
				}
			}
			if(id_str!='-'){
				$.ajax({
				    'type': 'GET',
				    'url':dobatchdelete,
				    'async':false,  
				    'contentType': 'application/json',
				    'data': {'id_str':id_str},
				    'dataType': 'json',
				    'success': function(data) {
				    	msg('批量删除成功！',1);
				    	console.log("success");
				    },
				    'error':function() {
				        console.log("error");
				    }
				});
			}
		}
	})
})
</script>
